<!DOCTYPE html>
<html>
<head>
    <title>{:env('env')=='test'?'【测试】':''}管理控制台 - {:config('base.site_title')}</title>
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <link rel="stylesheet" href="__PUBLIC_JS__/layui/css/layui.css?v={:config('hisiphp.version')}">
    <link rel="stylesheet" href="__ADMIN_CSS__/theme.css?v={:config('hisiphp.version')}">
    <link rel="stylesheet" href="__ADMIN_CSS__/style.css?v={:config('hisiphp.version')}">
    <link rel="stylesheet" href="__STATIC__/fonts/typicons/min.css?v={:config('hisiphp.version')}">
    <link rel="stylesheet" href="__STATIC__/fonts/font-awesome/min.css?v={:config('hisiphp.version')}">
    <style type="text/css">
        .hs-iframe{width:100%;height:100%;}
        .layui-tab{position:absolute;left:0;top:0;height:100%;width:100%;z-index:10;margin:0;border:none;overflow:hidden;}
        .layui-tab-content{padding:0 0 0 10px;height:100%;}
        .layui-tab-item{height:100%;}
        .footer{position:fixed;left:0;bottom:0;z-index:998;}
    </style>
</head>
<body class="hisi-theme-{:cookie('hisi_admin_theme')}">
{php}
$ca = strtolower(request()->controller().'/'.request()->action());
{/php}
<div class="layui-layout layui-layout-admin">
    {include file="system@block/menu" /}
    <div class="layui-body" id="switchBody">
        <div class="layui-tab layui-tab-card" lay-filter="hisiTab" lay-allowClose="true">
            <ul class="layui-tab-title" id="hisiTab">
                <li lay-id="0" class="layui-this">后台首页</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <iframe lay-id="0" src="{:url('index/welcome')}" width="100%" height="100%" frameborder="0" scrolling="yes" class="hs-iframe scroll-iframe"></iframe>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-footer footer">
        <span class="fl">Powered by <a href="{:config('base.site_domain')}" target="_blank">{:config('base.site_title')}</a> v{:config('hisiphp.version')}</span>
        <span class="fr"> 
        © 2013-{:date('Y')} <a href="{:config('base.site_domain')}" target="_blank">{:config('base.site_domain')}</a> All Rights Reserved.
        <div class="layui-btn-group pt10">
	        <button type="button" class="scroll-top iframe layui-btn-xs" title="跳至最顶部"><i class="typcn typcn-arrow-up-thick"></i></button>
	        <button type="button" class="scroll-bottom iframe layui-btn-xs" title="跳至最底部"><i class="typcn typcn-arrow-down-thick cyan"></i></button>
        </div>
        </span>
    </div>
</div>
<script type="text/javascript">
	var WEBSOCKET = "{:env('websocket')}";
</script>
{include file="system@block/layui" /}
<script type="text/javascript">
	var quickMenuIds = {:json_encode($quick_menu_ids)}; // 快捷菜单
	var hisiTabCurrentId = 0;
	var hisiTabIdScollData = new Array();
    layui.use(['jquery', 'element', 'layer'], function() {
        var $ = layui.jquery, element = layui.element, layer = layui.layer;      
        
        $('.layui-tab-content').height($(window).height() - 145);
        var tab = {
                add: function(title, url, id) {
					var starCss = quickMenuIds.indexOf(parseInt(id))!=-1?'yellow':'';          	
                    element.tabAdd('hisiTab', {
                        title: '<i class="layui-icon j-ajax '+starCss+'" data-href="{:url(\'system/menu/quick\')}?id='+id+'" data-id="'+id+'" refresh="false" callback="lightStar">&#xe600;&nbsp;</i>'+title,
                        content: '<iframe width="100%" height="100%" lay-id="'+id+'" frameborder="0" src="'+url+'" scrolling="yes" class="x-iframe scroll-iframe"></iframe>',
                        id: id
                    });
                }, change: function(id) {
                	hisiTabCurrentId = id;
                	element.tabChange('hisiTab', id);
                }
            };
     
        // tab切换监听，实现原tab浏览位置定位
        element.on('tab(hisiTab)', function(data){
        	var id = this.getAttribute('lay-id');
        	hisiTabCurrentId = id;
        	if (typeof(hisiTabIdScollData[id]) != "undefined" && hisiTabIdScollData[id] > 0) {
        		// iframe滚动到记录位置处
        		$("#switchBody .layui-tab-content .layui-show").children('iframe').contents().scrollTop(hisiTabIdScollData[id]);
        	}
        	//动态显示pv
            pv_uv_str(hisiTabCurrentId);
        });
     
        // 收藏点亮星星
        window.lightStar = function(obj, res){
        	var id = parseInt(obj.attr('data-id'));
        	if (res.code == 1) {
        		var d = res.data;
        		if (d.star == 1) {
        			obj.addClass('yellow');
        			quickMenuIds.push(id);
        		} else {
        			obj.removeClass('yellow');
        			var index = quickMenuIds.indexOf(id);
        			if(index != -1) quickMenuIds.splice(index, 1);
        		}
        	}
        };
        
        // 菜单点击
        $('.admin-nav-item').click(function(event) {
            var that = $(this), iframe = $('iframe[src="'+that.attr('href')+'"]');
            if (iframe[0]) {
                iframe.prop('src', iframe.attr('src'));
                tab.change(that.attr('data-id'));
                event.stopPropagation();
                return false;
            }
            
            if (!that.hasClass('top-nav-item')) {
                that.css({color:'#fff'});
            }
            tab.add(that.text(), that.attr('href'), that.attr('data-id'));
            tab.change(that.attr('data-id'));
            event.stopPropagation();
            return false;
        });

        // tab关闭
        $(document).on('click', '.layui-tab-close', function() {
            $('.layui-nav-child a[data-id="'+$(this).parent('li').attr('lay-id')+'"]').css({color:'rgba(255,255,255,.7)'});
        });
        
        
    });

</script>
</body>
</html>